package com.zb.service.impl;

import com.zb.dao.OrderMapper;
import com.zb.model.TOrder;
import com.zb.model.TOrderDetail;
import com.zb.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Service
public class OrderServiceImpl implements OrderService {

	@Autowired
	private OrderMapper lm;

	@Override
	public List<TOrder> findOrdersService(String userid) {
		List<TOrder> orderList = new ArrayList<>();
		orderList=lm.selectorder(userid);
		return orderList;
	}

	@Override
	public boolean qxOrdersService(String orderid) {
		boolean flag=lm.qxorder(orderid);
		return flag;
	}

	@Override
	public boolean addOrdersService(TOrder torder) {
		boolean flag=lm.addorder(torder);
		return flag;
	}

	@Override
	public boolean addOrderDetailService(TOrderDetail tod) {
		boolean flag=lm.addorderDetail(tod);
		return flag;
	}

	@Override
	public List<TOrderDetail> findOrderDetailService(String orderId) {
		List<TOrderDetail> todList = lm.selectorderDetail(orderId);
		return todList;
	}

	@Override
	public boolean reOrdersService(String orderid, String newStatus) {
		boolean flag=lm.reorderDetail(orderid,newStatus);
		return flag;
	}

	@Override
	public List<TOrder> findAllOrdersService() {
		List<TOrder> orderList =  lm.getAllOrder();
		return orderList;
	}
	@Override
	public List<TOrder> findOrdersByTimeService(Date begin,Date end){
		List<TOrder> orderList =  lm.getOrderByTime(begin,end);
		
		return orderList;
	}

	@Override
	public double getOrderSale(String orderId) {
		//每个订单的销售额
		return lm.getOrderSale(orderId);
	}

	@Override
	public double getOrderProfit(String orderId) {
		//计算某个订单的盈利
		return lm.getOrderProfit(orderId);
	}



}
